/** @ingroup keyboard
 * @file keyboard.h
 * @brief functions to convert PS/2 keyboard scancodes into keysymbols
 *
 * only scancode set 2 is supported. handles keyboard modifiers, leds and
 * converting scancodes into keysymbols
 *
 * @author cameris camerisdump@gmail.com
 */

#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_

#include <stdint.h>

/** @name keyboard hardware settings
 * @{ */
#define KBD_PIN   			PIND
#define KBD_PORT  			PORTD
#define KBD_DDR  			DDRD

#define KBD_DATA			PD3

#define KBD_CLOCK			PD2

#define KBD_INT_REG			EIMSK
#define KBD_INT				INT0

#define KBD_INT_FLAG_REG	EIFR
#define KBD_INT_FLAG		INTF0

#define KBD_INT_CTRL		EICRA
#define INT_ISC1			ISC01
#define INT_ISC0			ISC00

#define KBD_INT_VECT		INT0_vect
/**@} */

#define KEY_BUF_SIZE 16 /**< @brief size of the keysymbol buffer */
#define SC_BUF_SIZE 64 /**< @brief size of the scancode buffer */

#define KBD_TYPEMATIC 0x00  /**< @brief delay/repeat rate (250ms/30cps) */

void kbd_init(void);
void kbd_init_after_sei(void);
void kbd_set_numlock(uint_fast8_t b);
void kbd_set_capslock(uint_fast8_t b);
void kbd_set_scrolllock(uint_fast8_t b);
void kbd_disable(void);
void kbd_enable(void);
uint16_t kbd_get_key(void);
#endif
